<template>
  <div class="card mt-2" id="bill-detail-history">
    <div class="card-header text-center">
      <button
        type="button"
        class="btn btn-info btn-sm"
        @click.stop="searchHistories()"
      >
        查看操作记录
      </button>
    </div>
    <table class="table table-sm table-striped">
      <thead>
        <tr>
          <th>时间</th>
          <th>内容</th>
          <th>操作人</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="info in histories" :key="info.id">
          <td>{{ info.createTime }}</td>
          <td>{{ info.content }}</td>
          <td>{{ info.operator }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
import { searchBillInfoHistory } from "@/api/bill.js";

export default {
  props: {
    detailInfo: {
      type: Object,
    },
  },
  data() {
    return {
      histories: [],
    };
  },
  computed: {
    id() {
      return this.detailInfo.id;
    },
  },
  methods: {
    searchHistories: function () {
      searchBillInfoHistory(this.id, (v) => {
        this.histories = v;
      });
    },
  },
};
</script>